package com.mvc.model;



import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * 留言
 */

public class Message extends Model<Message> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7050666152955123299L;

	/***
	 * 表字段
	 *
	 */
	public static interface TableField {
		String ID = "id";
		String VENUEID = "venueId";
		String CONTENT = "content";
		String USERID = "userId";
	//	String TYPE = "type";
		String CREATETIME = "createTime";
		String NAME ="name";
	}

	public static final Message dao = new Message();

	public Venue getVenue() {
		return Venue.dao.findById(get("venueId"));
	}

	public User getUser() {
		return User.dao.findById(get("userId"));
	}

	public Page<Message> getNewPage(int pageNumber, int pageSize) {
		String select = "select m.*";
		String formwhere = "from message m where 1=1 order by m.createTime desc ";
		return dao.paginate(pageNumber, pageSize, select, formwhere);
	}

	public Page<Message> getVenuePage(int pageNumber, int pageSize, int venueId) {
		String select = "select m.*";
		String formwhere = "from message m where 1=1 and m.venueId=? order by m.createTime desc ";
		return dao.paginate(pageNumber, pageSize, select, formwhere, venueId);
	}

}
